<cfcomponent>
	<cffunction name="onIncomingMessage" output="false" access="remote" returntype="struct" hint="processes the amq queue message">
		<cfargument name="event" type="any" required="true"/>
		
		<cfset var stc = StructNew()><!--- to be RETURNED! --->
		<cfset var local = {} />
		<cfset var unsolvedState = 0 />
		<cfset var game = application.javaloader.create("State") />
		
		<cfset stc.status = 'EXCEPTION' /><!--- Must have a key of 'status' (see docs) --->
			
		<cftry>
			<cfset local.stateIDs = deserializeJSON(arguments.event.data.msg.stateIDs)>
			<!--- This is where my logic goes --->
			<cfloop array="#local.StateIDs#" index="local.stateID">
				<cfset request.messages = ArrayNew(1) />
				<cfset unsolvedState = application.db.getStateByID(local.stateID) />
				<cfset game.init(unsolvedState.state) />
				<cfset application.db.saveMoves(local.stateID, game.getLegalMoves()) />
				<cfset application.db.sendMessages() />
			</cfloop>			
			
			<cfset stc.status = 'OK' />
			
			<cfcatch type="any" >
				<cfset event.data.jmssession.rollback() />
				<!---
				<cfmail to="tmeyer@imagetrend.com" from="noreply@imagetrend.com" subject="dump">
					<cfdump var="#cfcatch#">
				</cfmail>--->
				<cfrethrow />
			</cfcatch>
		
		</cftry>
		
		<cfif stc.status eq "OK">
			<cfset event.data.jmssession.commit() />
		</cfif>
		
		<cfreturn stc />
	</cffunction>
	
	<!------>
</cfcomponent>